# Dir Rules
OBJDIRS += user

# extra includes and flags
USER_CFLAGS	:= -nostdinc
USER_LDFLAGS	:= -T user/user.ld -nostdinc

# all sources
USER_SRC :=	user/init.c

USER_EXE :=	user/init

# sources -> object files
USER_OBJ :=	$(patsubst %.c, $(OBJDIR)/%.o, $(USER_SRC))

SRCS 	+= $(USER_SRC)

# targets for all .c files
$(OBJDIR)/user/%.o: user/%.c
	@mkdir -p $(@D)
	$(CC) $(CFLAGS) $(USER_CFLAGS) -I$(INC) -c -o $@ $<

$(OBJDIR)/user/%: $(OBJDIR)/user/%.o $(OBJDIR)/lib/entry.o $(OBJDIR)/lib/libmain.o user/user.ld
	@mkdir -p $(@D)
	$(LD) $(USER_LDFLAGS) -o $@ $@.o $(OBJDIR)/lib/entry.o $(OBJDIR)/lib/libmain.o
	$(OBJDUMP) -S $@ > $@.asm
	$(NM) -n $@ > $@.sym

